import 'package:flutter/material.dart';

void main() => runApp(KaterialApp());



class KaterialApp extends StatefulWidget {
  @override
  _KaterialApp createState() => _KaterialApp();
}


class _KaterialApp extends State<KaterialApp> {

  int currentIndex = 0;

  void _changePage(int index) {
    if(index != currentIndex){
      setState(() {
        currentIndex = index;
      });
    }
  }
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
        title: '整体标题',
        home:
        new Scaffold(
          appBar: AppBar(
            title: Text('标题'),
            centerTitle: true,  // 默认 false  true 为屏幕正中间 false 为除去图标之后的正中间
            backgroundColor: Color.fromRGBO(255, 79, 2, 1), // 背景色
            primary: true, //此应用栏是否显示在屏幕顶部  默认true true不在屏幕最顶部，false 和时间、电量、信号那些在一排
            // title: new Text('Welcome to Flut3232ter'),
            leading:   IconButton(
              icon: const Icon(Icons.menu),
              tooltip: 'Next page',
              onPressed: () {
              },
            ),
            actions:<Widget>[
              IconButton(
                icon: const Icon(Icons.add_alert),
                tooltip: 'Show Snackbar',
                onPressed: () {

                },
              ),
              IconButton(
                icon: const Icon(Icons.navigate_next),
                tooltip: 'Next page',
                onPressed: () {
                },
              ),
            ] ,

          ),
          backgroundColor:Color(0xFFff4f02),
          bottomNavigationBar: new BottomNavigationBar(
            items: [
              new BottomNavigationBarItem(
                  backgroundColor: Colors.blue,
                  icon: Icon(Icons.home),
                  label:"首页"
              ),

              new BottomNavigationBarItem(
                  backgroundColor: Colors.green,
                  icon: Icon(Icons.message),
                  label: '消息'
              ),

              new BottomNavigationBarItem(
                  backgroundColor: Colors.amber,
                  icon: Icon(Icons.shopping_cart),
                  label: "购物车"
              ),
              new BottomNavigationBarItem(
                  backgroundColor: Colors.red,
                  icon: Icon(Icons.person),
                  label: '个人中心'
              )
            ],
            currentIndex: currentIndex,
            type: BottomNavigationBarType.fixed, //每行一样大，默认不是这种
            selectedItemColor: Color(0xffff4f02),
            backgroundColor: Color(0xffcccccc),
            selectedFontSize: 20, //选中文字的大小

            onTap: (index) {
              _changePage(index);
            },
          ),
          body: Text('内容'),
        )
    );
  }
}

